<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="../css/bootstrap4.5.min.css">
    <link rel="stylesheet" href="../css/public.css">
    <script src="../js/jquery-3.5.1.min.js"></script>
    <title>Document</title>
    <style>
        .com_form_box_two label {
            color: var(--c_text);
            font-size: var(--f_notes);
            line-height: var(--l_notes);
            text-align: center;
            width: 64px;
            height: 29px;
            margin-bottom: 0;
            overflow: hidden;
        }

        .com_form_flex_one {
            display: flex;
            flex-direction: row-reverse;
        }

        .com_form_box_two label span {
            color: red;
            padding-right: 8px;
            display: inline-block;
        }

        .com_form_box_two li {
            padding-right: 0;
        }

        .com_form_box_two li {
            padding: 0;
            padding-bottom: 26px;
        }
        .com_form_box_two li:last-child {
            padding-top: 40px;
        }
        .com_form_box_two,
        .com_form_box_two li,
        .public_bottom_map {
            padding: 0;
        }

        .com_form_flex_one .com_form_box_two {
            padding-left: 20px;
        }

        .com_form_flex_one .public_bottom_map {
            padding-right: 20px;
        }

        .com_form_box_two input {
            font-size: 16px;
            width: 100%;
            padding-left: 10px;
        }

        .com_form_box_two textarea {
            width: 100%;
            padding-left: 10px;
            height: 120px;
            resize: none;
            font-size: 16px;
        }

        .width_details {
            width: 560px;
            margin: auto;
        }

        .com_form_box_two a {
            display: block;
            width: 200px;
            height: 32px;
            line-height: 32px;
            text-align: center;
            color: var(--c_b_nav);
            font-size: 18px;
            background-color: var(--c_theme);
            border: 1px solid var(--c_text);
            transition: 1s;
        }


        @media (max-width:768px) {
            .com_form_box_two a {
                width: 100px;
                margin: auto;
            }

            .com_form_box_two input,
            .com_form_box_two textarea {
                font-size: 12px;
            }

            .com_form_flex_one .com_form .com_form_box_two {
                padding: 0;
                margin: auto;
            }

            .com_form_box_two li {
                padding: 0 1px 20px;
            }

            .com_form_flex_one li:last-child {
                padding-bottom: 0;
            }
        }

        @media (max-width:560px) {
            .width_details {
                width: 100%;
            }

            .com_form_box_two a {
                width: 100%;
            }

        }

        .com_form_box_hint_two,
        .com_form_box_hint_one,
        .com_form_box_hint_three,
        .com_form_box_hint_four {
            padding-left: 100px;
            color: #999;
            text-align: left;
            font-size: 16px;
        }

        .wong {
            color: green;
            text-align: left;
            padding-left: 100px;
            font-size: 16px;
        }

        @media (max-width:768px) {

            .com_form_box_hint_two,
            .com_form_box_hint_one,
            .com_form_box_hint_three,
            .com_form_box_hint_four {
                padding-left: 50px;
                color: #999;
                text-align: left;
                font-size: 12px;
            }

            .wong {
                color: green;
                text-align: left;
                padding-left: 50px;
                font-size: 12px;
            }

            .com_form_flex_one .com_form_box_two {
                order: 2;
                padding-left: 0;
            }

            .com_form_flex_one .public_bottom_map {
                order: 1;
                padding-bottom: 20px;
            }

            .com_form_flex_one .public_bottom_map {
                width: 100%;
                padding-right: 0;
            }

            .com_form_flex_one li {
                padding-left: 0;
            }

            .public_bottom_map #dituContent {
                height: 260px;
            }
        }

        /* .number {
            border: none;
        } */
        .com_form_box_show {
            border: none;
            border: 1px solid red;
        }

        .com_form_box_pass {
            border: none;
            border: 1px solid green;
        }

        .rong {
            color: red;

        }


        /* 地图 */
        .iw_poi_title {
            color: #CC5522;
            font-size: 14px;
            font-weight: bold;
            overflow: hidden;
            padding-right: 13px;
            white-space: nowrap
        }

        .BMap_omCtrl,
        .BMap_omOutFrame {
            display: none;
        }

        .iw_poi_content {
            font: 12px arial, sans-serif;
            overflow: visible;
            padding-top: 4px;
            white-space: -moz-pre-wrap;
            word-wrap: break-word
        }

        .public_bottom_map {
            margin: auto;
        }

        .contactUs_flexBox3 .public_bottom_map {
            width: 100%;
        }

        .public_bottom_map #dituContent {
            width: 100%;
            height: 341px;
        }
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?key=&v=1.1&services=true"></script>
</head>

<body>
    <div class="com_form modular">
        <div class="public_width">
            <div class="com_form_flex_one row">
                <ul class="com_form_box_two col-xl-6 col-md-6 col-12">
                    <li>
                        <div class="com_form_box_text">
                            <label for="name1"><span>*</span>姓名:</label>
                        </div>
                        <input type="text" placeholder="请输入您的姓名" id="name1" autofocus class="name">
                        <p class="com_form_box_hint_one"></p>
                    </li>
                    <li>
                        <div class="com_form_box_text">
                            <div class="com_form_box_text">
                                <label for="name1"><span>*</span>电话:</label>
                            </div>
                        </div>
                        <input type="text" placeholder="请输入您的手机号" id="name2" class="number"><br />
                        <p class="com_form_box_hint_two"></p>
                    </li>
                    <li>
                        <div class="com_form_box_text">
                            <label for="name1"><span>*</span>QQ :</label>
                        </div>
                        <input type="text" placeholder="请输入您的QQ号码" id="name3" class="QQnumber">
                        <p class="com_form_box_hint_three"></p>
                    </li>
                    <li>
                        <div class="com_form_box_text">
                            <label for="name1"><span>*</span>邮箱:</label>
                        </div>
                        <input type="email" placeholder="请输入您的邮箱" id="name4" class="email">
                        <p class="com_form_box_hint_four"></p>
                    </li>
                    <li>
                        <div class="com_form_box_text">
                            <label for="name5"><span>*</span>备注:</label></div>
                        <textarea name="" id="name5" cols="30" rows="10" placeholder="请输入您的留言"></textarea>
                    </li>
                    <li class="col-12">
                        <a href="">立即发布</a>
                    </li>
                </ul>
                <div class="public_bottom_map col-xl-6 col-md-6 col-12">
                    <div id="dituContent"></div>
                </div>
            </div>
        </div>
    </div>
    <script>
        // 1、姓名
        var nameone = document.querySelector('.name') //姓名  
        var com_form_box_hint1 = document.querySelector('.com_form_box_hint_one')
        var userName = /^[a-zA-Z][0-9a-zA-Z]{6,20}$/
        nameone.onblur = function () {
            if (this.value.length < 1 || this.value.length > 16 || userName.test(nameone.value) != true) {
                com_form_box_hint1.className = "com_form_box_hint_one rong";
                nameone.className = "name com_form_box_show";
                com_form_box_hint1.innerHTML = "请输入7到16位以纯英文字母开头或者和数字组成的名字!"
            } else {
                com_form_box_hint1.className = "com_form_box_hint wong";
                nameone.className = "name com_form_box_pass";
                com_form_box_hint1.innerHTML = " "
            }
        }
        // 2、电话
        // 1、获取元素
        var number = document.querySelector('.number'); //号码
        var com_form_box_hint2 = document.querySelector('.com_form_box_hint_two');
        var checkout = /^1[3456789]\d{9}$/
        // 2、注册事件，失去焦点
        number.onblur = function () {
            // 根据value长度判断是否是6到16位
            if (checkout.test(number.value) != true) {
                com_form_box_hint2.className = "com_form_box_hint_two rong";
                number.className = "number com_form_box_show";
                com_form_box_hint2.innerHTML = "请输入11位数中国大陆正确格式的号码!"
            } else {
                com_form_box_hint2.className = "com_form_box_hint_two wong";
                number.className = "number com_form_box_pass";
                // com_form_box_hint2.innerHTML = "✔ 输入正确！"
                com_form_box_hint3.innerHTML = " "

            }
        }
        // 3、QQ
        // 1、获取元素
        var qqnumber = document.querySelector('.QQnumber') //QQ
        var com_form_box_hint3 = document.querySelector('.com_form_box_hint_three')
        // 2、注册事件，失去焦点
        qqnumber.onblur = function () {
            // 根据value长度
            if (this.value.length < 5 || this.value.length > 10) {
                com_form_box_hint3.className = "com_form_box_hint_three rong";
                qqnumber.className = "QQnumber com_form_box_show";
                com_form_box_hint3.innerHTML = "请输入5到9位的QQ号码!"

            } else {
                com_form_box_hint3.className = "com_form_box_hint_three wong";
                qqnumber.className = "QQnumber com_form_box_pass";
                com_form_box_hint3.innerHTML = " "

            }
        }
        // 4、邮箱
        // 1、获取元素
        var emailnumber = document.querySelector('.email') //QQ
        var com_form_box_hint4 = document.querySelector('.com_form_box_hint_four')
        var impose = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
        // 2、注册事件，失去焦点
        emailnumber.onblur = function () {
            // 根据value长度
            if (impose.test(emailnumber.value) != true) {
                com_form_box_hint4.className = "com_form_box_hint_four rong";
                emailnumber.className = "email com_form_box_show";
                com_form_box_hint4.innerHTML = "请输入正确的邮箱格式!"

            } else {
                com_form_box_hint4.className = "com_form_box_hint_four wong";
                emailnumber.className = "email com_form_box_pass";
                com_form_box_hint4.innerHTML = " "
            }
        }
    </script>
    <script type="text/javascript">
        //创建和初始化地图函数：
        function initMap() {
            createMap(); //创建地图
            setMapEvent(); //设置地图事件
            addMapControl(); //向地图添加控件
            addMarker(); //向地图中添加marker
        }

        //创建地图函数：
        function createMap() {
            var map = new BMap.Map("dituContent"); //在百度地图容器中创建一个地图
            var point = new BMap.Point(109.396017, 24.292992); //定义一个中心点坐标
            map.centerAndZoom(point, 17); //设定地图的中心点和坐标并将地图显示在地图容器中
            window.map = map; //将map变量存储在全局
        }

        //地图事件设置函数：
        function setMapEvent() {
            map.enableDragging(); //启用地图拖拽事件，默认启用(可不写)
            map.enableScrollWheelZoom(); //启用地图滚轮放大缩小
            map.enableDoubleClickZoom(); //启用鼠标双击放大，默认启用(可不写)
            map.enableKeyboard(); //启用键盘上下左右键移动地图
        }

        //地图控件添加函数：
        function addMapControl() {
            //向地图中添加缩放控件
            var ctrl_nav = new BMap.NavigationControl({
                anchor: BMAP_ANCHOR_TOP_LEFT,
                type: BMAP_NAVIGATION_CONTROL_LARGE
            });
            map.addControl(ctrl_nav);
            //向地图中添加缩略图控件
            var ctrl_ove = new BMap.OverviewMapControl({
                anchor: BMAP_ANCHOR_BOTTOM_RIGHT,
                isOpen: 1
            });
            map.addControl(ctrl_ove);
            //向地图中添加比例尺控件
            var ctrl_sca = new BMap.ScaleControl({
                anchor: BMAP_ANCHOR_BOTTOM_LEFT
            });
            map.addControl(ctrl_sca);
        }

        //标注点数组
        var markerArr = [{
            title: "展览设计",
            content: "展览设计",
            point: "109.397086|24.292992",
            isOpen: 1,
            icon: {
                w: 21,
                h: 21,
                l: 0,
                t: 0,
                x: 6,
                lb: 5
            }
        }];
        //创建marker
        function addMarker() {
            for (var i = 0; i < markerArr.length; i++) {
                var json = markerArr[i];
                var p0 = json.point.split("|")[0];
                var p1 = json.point.split("|")[1];
                var point = new BMap.Point(p0, p1);
                var iconImg = createIcon(json.icon);
                var marker = new BMap.Marker(point, {
                    icon: iconImg
                });
                var iw = createInfoWindow(i);
                var label = new BMap.Label(json.title, {
                    "offset": new BMap.Size(json.icon.lb - json.icon.x + 10, -20)
                });
                marker.setLabel(label);
                map.addOverlay(marker);
                label.setStyle({
                    borderColor: "#808080",
                    color: "#333",
                    cursor: "pointer"
                });

                (function () {
                    var index = i;
                    var _iw = createInfoWindow(i);
                    var _marker = marker;
                    _marker.addEventListener("click", function () {
                        this.openInfoWindow(_iw);
                    });
                    _iw.addEventListener("open", function () {
                        _marker.getLabel().hide();
                    })
                    _iw.addEventListener("close", function () {
                        _marker.getLabel().show();
                    })
                    label.addEventListener("click", function () {
                        _marker.openInfoWindow(_iw);
                    })
                    if (!!json.isOpen) {
                        label.hide();
                        _marker.openInfoWindow(_iw);
                    }
                })()
            }
        }
        //创建InfoWindow
        function createInfoWindow(i) {
            var json = markerArr[i];
            var iw = new BMap.InfoWindow("<b class='iw_poi_title' title='" + json.title + "'>" + json.title +
                "</b><div class='iw_poi_content'>" + json.content + "</div>");
            return iw;
        }
        //创建一个Icon
        function createIcon(json) {
            var icon = new BMap.Icon("http://app.baidu.com/map/images/us_mk_icon.png", new BMap.Size(json.w, json.h), {
                imageOffset: new BMap.Size(-json.l, -json.t),
                infoWindowOffset: new BMap.Size(json.lb + 5, 1),
                offset: new BMap.Size(json.x, json.h)
            })
            return icon;
        }

        initMap(); //创建和初始化地图
    </script>
</body>

</html>